package dp;

import java.util.Arrays;

public class dp673 {
    public static void main(String[] args) {
        System.out.println(findNumberOfLIS(new int[]{1,1,1,1,1}));
    }
    public static int findNumberOfLIS(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n];
        int[] count = new int[n];
        Arrays.fill(dp,1);
        Arrays.fill(count,1);
        int re = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if(nums[i] > nums[j]){
                    if(dp[j] + 1 > dp[i])
                        count[i] = count[j];
                    if(dp[j] + 1 == dp[i])
                        count[i] += count[j];
                    dp[i] = Math.max(dp[j] + 1, dp[i]);
                    re = Math.max(re, dp[i]);
                }

            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if(re == dp[i])
                ans += count[i];
        }
        return ans;
    }
}
